package com.pomr.util.common;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import javax.servlet.http.HttpServletRequest;

import com.alibaba.fastjson.JSONObject;

public class RequestParams {
	
	public static String getParams(HttpServletRequest request){
		try {
			StringBuffer sb = new StringBuffer() ;   
	        InputStream is = request.getInputStream();   
	        BufferedReader br = new BufferedReader(new InputStreamReader(is,"utf-8"));   
	        String s = "" ;   
	        while((s=br.readLine())!=null){   
	            sb.append(s) ;   
	        }   
	        JSONObject js = null;
	        if(sb.toString().trim().length()<=0){  
	        	js = null;  
	        }else {  
	        	if(sb.toString().trim().length() == 2){
	        		js = null;
	        	}else{
	        		js = JSONObject.parseObject(sb.toString());
	        	}
	        } 
	        if(js==null){  
	        	return "";
	        }else{
	        	return js.toJSONString();
	        }
		} catch (Exception e) {
			e.printStackTrace();
			return "异常"+e.getMessage();
		}
	}

}
